{% extends "layout.html" %}
{%block stylesheets%}
{{super()}}
{{css("items/show")}}
{%if current_user%} {{css('rich-text')}} {%endif%}
{%endblock%}
{%block javascript%}
{{super()}}
{%if current_user%} {{js('items/list')}} {{js('rich-text')}} {%endif%}
{%endblock%}
{% set title=item.name %}
{%block content%}
{%from 'items/macros.html' import item_actions with context%}
<div id="right">
	<div class="name">{{item.name}}</div>
	<div class="thumbnail" style="background-image:url('{{item|url(named=False,action='picture')}}')"></div>
	{{item_actions(item)}}
</div>
<div id="price"><span class="label">Price:</span> {{item.price|price}}</div>
<a id="owner" href="{{item.parent()|url}}">{{item.parent().nickname}}</a>
<div id="expiration">Created on {{item.creation_time|date}}<br/>Expires on {{item.expiration()|date}}</div>
<div id="description">
	{{item.description|Markup}}
</div>
<div id="clearer"></div>
{%if current_user and item.parent_key()!=current_user.key() %}
<h2>Rate this Item</h2>
<form method="post" action="{{item|url(named=False,action='rate')}}" id="rating-form" data-completing-label="Submitting...">
	{{csrf_field()}}
	<div class="numerical-rating">
		<input type="radio" style="left:0px"   name="rating" value="100"/>
		<input type="radio" style="left:30px"  name="rating" value="80"/>
		<input type="radio" style="left:60px"  name="rating" value="60"/>
		<input type="radio" style="left:90px"  name="rating" value="40"/>
		<input type="radio" style="left:120px" name="rating" value="20"/>
	</div>
	<textarea name="contents"></textarea>
	<div class="rich-text" data-form="rating-form" data-field="contents"></div>
	<input type="submit" value="Submit"/>
</form>
{%endif%}
<h2>
	Ratings
	<div class="star-strip large" id="average-rating">
		<div style="width:{{item.avg_rating}}%"></div>
	</div>
	<div class="clearer"></div>
</h2>
{%for rating in ratings%}
<div class="rating">
	<div class="margin">
		<a class="user" href="{{rating.parent()|url}}">
			<div class="pic" style="background-image:url('{{rating.parent().url(action='thumbnail')}}')"></div>
			<div class="name">{{rating.parent().nickname}}</div>
		</a>
		{%if current_user and current_user.admin%}
		<form method="post" action="/items/delete-rating" class="delete-form">
			{{csrf_field()}}
			<input type="hidden" name="rating" value="{{rating.key()}}"/>
			<input type="submit" value="Delete"/>
		</form>
		{%endif%}
	</div>
	<div class="message">
		<div class="star-strip">
			<div style="width:{{rating.rating}}%"></div>
		</div>
		{{rating.contents|Markup}}
	</div>
	
	<div class="clearer"></div>
</div>
{%endfor%}
{%endblock%}